package com.lovo.test.ATM;

import com.lovo.test.ATM.ATM;
import com.lovo.test.Util.Util;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

//登陆界面
public class LoginPanel extends JPanel implements ActionListener {
    //以下是图片封装
    private Icon loginImg = Util.getIcon("/ATMimages/buttonLand.jpg");//登录按键
    private Icon registerImg = Util.getIcon("/ATMimages/buttonLogin.jpg");//注册按键


    private ATM frame;//包含ATM。JFrame 对象


    private JButton loginBut;//登陆按钮对象
    private JButton registerBut;//注册按钮对象

    public LoginPanel(ATM frame){
        this.frame=frame;

        //背景图片


        this.setLayout(null);

        //设置透明
        this.setOpaque(false);
        //登陆按钮
        loginBut = new JButton(loginImg);
        loginBut.setBounds(200,330,140,50);
        this.add(loginBut);
        loginBut.addActionListener(this);

        //注册按钮
        registerBut = new JButton(registerImg);
        registerBut.setBounds(460,330,140,50);
        this.add(registerBut);
        registerBut.addActionListener(this);

    }



    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource()==loginBut){
            frame.switchPanel("菜单");

        }else if (e.getSource()==registerBut){

        }
    }
}
